package com.qdlc.p2p.biz.model;

import java.util.HashMap;
import java.util.Map;

import com.qdlc.p2p.biz.util.ValidateUtil;
import com.qdlc.p2p.common.constant.NoticeTplNid;
import com.qdlc.p2p.common.util.PropertiesUtil;
import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.model.UserModel;

/**
 * 发送手机验证码接口 model
 * @author wj1x
 * @version 2.0
 * @date 2015年6月18日 下午6:12:36
 */
public class AppCodeModel extends UserModel{
	
	
	/**获取方式*/
	private String type;
	
	/**验证码*/
	private String code;
	
	/**验证码接收地址*/
	private String receiveAddr;			

	/**验证码类型*/
	private String noticeId;		

	/**
	 * 验证码状态
	 */
	private byte bnoticeType;
	
	


	public String getNoticeId() {
		return noticeId;
	}


	public void setNoticeId(String noticeId) {
		this.noticeId = noticeId;
	}


	private Map<String,Object> data;
	
	/**
	 * 获取验证码参数 校验
	 * @return
	 */
	public Map<String,Object> validParam(){
		data = new HashMap<String,Object>();
		if(StringUtil.isBlank(getReceiveAddr())){						//接收验证码地址
			data.put("resCode", "01");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction01"));
			return data;
		}
		if(StringUtil.isBlank(getType())){								//获取验证码类型
			data.put("resCode", "02");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction02"));
			return data;
		}
		if(StringUtil.isBlank(getNoticeId())){								//验证码类型
			data.put("resCode", "03");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction03"));
			return data;
		}
		return null;
	}

	/**
	 * 校验验证码参数 校验
	 * @return
	 */
	public Map<String,Object> validParams(){
		data = new HashMap<String,Object>();
		if(StringUtil.isBlank(getCode())){
			data.put("resCode", "01");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction01"));
			return data;
		}
		if(StringUtil.isBlank(getReceiveAddr())){
			data.put("resCode", "02");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction02"));
			return data;
		}
		if(StringUtil.isBlank(getNoticeId())){
			data.put("resCode", "03");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction03"));
			return data;
		}
		return null;
	}
	
	/**
	 * 
	 * @return
	 */
	public Map<String,Object> checkResponse(){
		if (!ValidateUtil.checkCode(getCode(), getNoticeId(), getReceiveAddr(), NoticeTplNid.NOTICE_SMS)) {
			data.put("resCode", "0");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction04"));
		}else{
			data.put("resCode", "1");
			data.put("resMsg", PropertiesUtil.getValue("AppGetCodeAction05"));
		}
		return data;
	}
	
	


	public byte getBnoticeType() {
		return bnoticeType;
	}


	public void setBnoticeType(byte bnoticeType) {
		this.bnoticeType = bnoticeType;
	}


	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Map<String, Object> getData() {
		return data;
	}


	public void setData(Map<String, Object> data) {
		this.data = data;
	}
	
	public String getReceiveAddr() {
		return receiveAddr;
	}

	public void setReceiveAddr(String receiveAddr) {
		this.receiveAddr = receiveAddr;
	}

	

	

	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}
	
}
